#include "../include/MainServer.h"

using namespace std;

int main() {
    IdManager::initIdManager();
    IdManager* idManager = IdManager::getIdManager();
    idManager->registered("SmartCar","cqusn",16);
    idManager->registered("STU","E2019",8);
    idManager->registered("COMPARE","CP",8);
    idManager->loadData();
    CarController* carController = new CarController();
    StudentController* stuController = new StudentController();
    CompareController* compareController = new CompareController();

    string cmd;
    while(cmd != E_X_I_T) {
        cout << "======智能小车管理总界面======" << endl;
        cout << "指令说明:" << endl;
        cout << "1. manageSmartCar      管理智能小车" << endl;
        cout << "2. manageStudent       管理学生" << endl;
        cout << "3. manageCompare       管理分配" << endl;
        cout << "4. showInfo            展示信息" << endl;
        cin >> cmd;
        if(cmd == "1") {
            manageSmartCar(carController);
        }
        else if(cmd == "2") {
            manageStudent(stuController);
        }
        else if(cmd == "3") {
            manageCompare(compareController,stuController,carController);
        }
        else if(cmd == "4") {
            showInfo(compareController,stuController,carController);
        }
        cout << "=============================" << endl;
    }
    cout << "INFO: 是否需要保存数据? (1:保存 others:不保存)" << endl;
    cin >> cmd;
    if(cmd == "1") {
        // TODO 当数据未修改时,不应该保存
        // storeCarData();
        // storeStudentData();
        // storeCompareData();
        idManager->saveData();
    }

    
    delete carController;
    delete stuController;
    delete compareController;
    IdManager::deteleIdManager;
    return 0;
}
